@extends('template.adminpage')
@section('content')
 
<ol class="breadcrumb">
  <li><a href="{{URL::to('/order/onprocessorder')}}">On proses order</a></li>
  <li class="active">Progress</li>
</ol>
<?php
        if($progress->order_name=='idcard'){$ordername = 'ID Card';}
        else if($progress->order_name=='packaging'){$ordername = 'Packaging';}
        else if($progress->order_name=='brosur'){$ordername = 'Brosur';}
        else if($progress->order_name=='nota'){$ordername = 'Nota';}
        else if($progress->order_name=='kaos'){$ordername = 'T-Shirt';}
        ?>
<div class="container-black">
  <label style="margin-top:10px"><u>Summary status</u></label>
      <div class="row">
      <div class="col-md-6">
      <div class="row">
        <div class="col-lg-3 col-md-offset-1">
        Kode order
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{$progress->order_code}}</label>
        </div>
      </div>
      <br>
      <div class="row">
        <div class="col-lg-3 col-md-offset-1">
        Tanggal order
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{date("d-M-Y",strtotime($progress->order_date))}}</label>
        </div>
      </div>
      <br>
      <div class="row">
        <div class="col-lg-3 col-md-offset-1">
        Jenis order
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
           <label>{{$ordername}}</label>
        </div>
      </div>
      </div>

      <div class="col-md-6">
      <div class="row">
        <div class="col-lg-4">
        Jumlah order (QTY)
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{$progress->order_qty.' '.$progress->order_qty_unit}}</label>
        </div>
      </div>
      <br>

      <div class="row">
        <div class="col-lg-4">
        Selesai (QTY)
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{$total->order_progress_qty_finished.' '.$progress->order_qty_unit}}</label>
        </div>
      </div>
      <br>
      <div class="row">
        <div class="col-lg-4">
        Terkirim (QTY)
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{$total->order_progress_qty_delivered.' '.$progress->order_qty_unit}}</label>
        </div>
      </div>
      <br>
      <div class="row">
        <div class="col-lg-4">
        Outstanding (QTY)
        </div>
        <div class="col-md-1">
          :
        </div>
        <div class="col-lg-7">
          <label>{{$progress->order_qty-$total->order_progress_qty_finished.' '.$progress->order_qty_unit}}</label>
        </div>
      </div>
      </div>
      </div>
      <br>

  <label><u>Detail summary status</u></label>
    <br>
    <form action="{{URL::to('/order/onprocessorder/progress/deleteprogress/'.$progress->order_id)}}"  method="post" >
    <p><a data-toggle="modal" data-target="#add"><button class="btn btn-sm btn-dark" style="height:30px" ><span class="fa fa-plus"></span> Tambah</button></a> <button class="btn btn-sm btn-dark" type="submit" style="height:30px" ><span class="fa  fa-times"></span> Hapus</button></p>
    <div class="table-responsive">
     <table class="table table-bordered table-hover">
      <thead>
        <tr>
          <th><input type="checkbox" name="checkall" id="terserah" onclick="check_all('terserah', 1)" ></input></th>
          <th>No</th>
          <th>Total order (Qty)</th>
          <th>Selesai dikerjakan (Qty) / Tgl</th>
          <th>Dikirimkan (Qty) / Tgl</th>
          <th>Outstanding proses (Qty)</th>
        </tr>
      </thead>
      <tbody>
      <?php 
          $no=1; 
          $totalfinished = 0;
      ?>
      @foreach($detailprogress as $detail)
          <?php
          $finished = DB::table('sys_order_progress_log')
                  ->where('order_progress_log_id','=',$detail->order_progress_log_id)
                  ->where('order_progress_log_status','=','Finished')
                  ->groupBy('order_progress_log_order_id')
                  ->get();
          $delivered = DB::table('sys_order_progress_log')
                  ->where('order_progress_log_id','=',$detail->order_progress_log_id)
                  ->where('order_progress_log_status','=','Delivered')
                  ->get();

          ?>
           <td><input type="checkbox" name="{{$detail->order_progress_log_id}}" value="1" id="terserah_{{$no}}" ></input></td>
          <td>{{$no}}</td>
          <td>{{$progress->order_qty.' '.$progress->order_qty_unit}}</td>
          <td><?php foreach($finished as $finish){ echo $finish->order_progress_log_qty.' '.$progress->order_qty_unit.' / '.date("d-M-Y h:i",strtotime($finish->order_progress_log_date)); } ?></td>
          <td><?php foreach($delivered as $delivered){ echo $delivered->order_progress_log_qty.' '.$progress->order_qty_unit.' / '.date("d-M-Y h:i",strtotime($delivered->order_progress_log_date)); } ?></td>
          <td><?php foreach($finished as $finished){  $totalfinished = $totalfinished+$finished->order_progress_log_qty; $outstanding = $progress->order_qty-$totalfinished;} ?>{{$outstanding.' '.$progress->order_qty_unit}}</td>
          
      </tbody>
      <?php $no++; ?>
      @endforeach
    </table>
  </form>
  </div>
              <div class="modal fade" id="add" tabindex="-1" role="dialog" aria-labelledby="myLargeModalLabel" aria-hidden="false">
                <div class="modal-dialog modal-lg">
                  <div class="modal-content">
                    <div class="modal-header">
                    <button type="button" class="close" data-dismiss="modal" aria-hidden="true">&times;</button>
 
                    <h4 align="center" class="modal-title"> <label style="margin-top:5px; margin-bottom:25px">Tambah progress </label></h4>
                    </div>
                    <div align="left">
                                 {{Form::open(array(
                                    'url' => '/order/onprocessorder/progress/addprogress/'.$progress->order_id,
                                    'method' => 'POST'
                                  ))}}
                              <div class="row" style="margin-top:10px">
                              <div class="col-md-10 col-md-offset-1">
                                 

                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Total order (QTY)</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="text"  class="form-control" style="width:200px;height:30px" value="{{$progress->order_qty.' '.$progress->order_qty_unit}}" disabled /></input>
                                  </div>
                                  </div>
                                  <br>

                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Outstanding (QTY)</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="text"  class="form-control" style="width:200px;height:30px" value="{{$progress->order_qty-$total->order_progress_qty_finished.' '.$progress->order_qty_unit}}" disabled /></input>
                                  </div>
                                  </div>
                                  <br>

                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Selesai (QTY)</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="number" min="1" max="{{$progress->order_qty-$total->order_progress_qty_finished}}" class="form-control" style="width:200px;height:30px" name="finished" /></input>
                                  </div>
                                  </div>
                                  <br>

                                  <div class="row">
                                  <div class="col-lg-4">
                                  <label>Terkirim (QTY)</label>
                                  </div>
                                  <div class="col-lg-4">
                                    <input type="number" min="1" max="{{$progress->order_qty-$total->order_progress_qty_delivered}}" class="form-control" style="width:200px;height:30px" name="delivered"  /></input>
                                  </div>
                                  </div>
                                  <br>
                                 
                                
                              </div> 
                              </div>   
                    
                    </div>
                    <div class="modal-footer">

                    <button type="submit" class="btn btn-sm btn-dark"><span class="fa fa-floppy-o"></span> Simpan</button>{{Form::close()}} <button class="btn btn-sm btn-dark" style="margin-right:5px" class="close" data-dismiss="modal"><span class="fa fa-times"></span> Batal</button></a>
                         
                    </div>
                  </div>
                </div>
              </div>

            
</div>


@stop
@stop